#pragma once

#include "gameobject.h"
#include "../SGD Wrappers/SGD_Math.h"
#include "Events\IListener.h"

class LaserEmitter : public GameObject, public IListener
{
private:

	float range;
	float heatValue;
	tVector2D direction;
	tVector2D center;
	tVector2D renderLine;
	unsigned int linecastFrequency;
	bool isPowered;
	bool PoweredOnStart;

	LaserEmitter* checkpointSave;

public:
	// Constructor
	LaserEmitter(void);

	// Destructor
	~LaserEmitter(void);

	//////////////////////////////////////////////////
	// GameObject Methods:
	void Update(float deltaTime)									override;
	void Render(void) const											override;
	void HandleCollision(GameObject& other, CollisionInfo& info)	override;
	void ResetToCheckPoint()										override;

	//////////////////////////////////////////////////
	// Accessors:
	inline float GetRange(void) const { return range; }
	inline float GetHeatValue(void) const { return heatValue; }
	inline tVector2D GetDirection(void) const { return direction; }
	inline unsigned int GetLinecastFrequency(void) const { return linecastFrequency - 1; }
	inline bool GetPoweredOnStart(void) const { return PoweredOnStart; }

	//////////////////////////////////////////////////
	// Mutators:
	void SetRange(float range);
	void SetHeatValue(float heat);
	void SetDirection(float x, float y);
	void SetDirection(tVector2D direction);
	void SetLinecastFrequency(unsigned int frequency);
	void SetIsPowered(bool power);
	void SetPoweredOnStart(bool PoweredToStart );

	//HandleEvents
	void HandleEvent(Event* pEvent);

private:
	//////////////////////////////////////////////////
	// Helper Functions:
	void DrawLaser(int x1, int y1, int x2, int y2, int iterations) const;
};

